package org.jsbd.boss.service.impl;

import org.apache.commons.lang.StringUtils;
import org.jsbd.boss.dao.IBrushConfigDao;
import org.jsbd.boss.domian.channel.BrushConfig;
import org.jsbd.boss.service.IBrushConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("brushConfigService")
public class BrushConfigServiceImpl implements IBrushConfigService{
    @Autowired
    private IBrushConfigDao brushConfigDao;
	
	@Override
	public boolean checkBrushUrl(Integer id, String url) {
		BrushConfig cofig = brushConfigDao.selectById(id);
		if (cofig == null) {
			return false;
		}
		if (StringUtils.isNotBlank(cofig.getPrefix())) {
			if (!url.contains(cofig.getPrefix())) {
				return false;
			}
		}
		if (StringUtils.isNotBlank(cofig.getSuffix())) {
			if (!url.contains(cofig.getSuffix())) {
				return false;
			}	
		}
		
		return true;
	}

}
